<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><!-- InstanceBegin template="/Templates/instructions_template.dwt" codeOutsideHTMLIsLocked="false" -->
  <head>
  <!-- InstanceBeginEditable name="doctitle" -->
  <title>EJB 2.0 Stateless Session EJB</title>
<!-- InstanceEndEditable -->
  
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
  
  <link href="../../../../../../../docs/css/samples.css" rel="stylesheet" title="Style" type="text/css" />
  
  <script language="JavaScript" src="../../../../../../../docs/core/topicInfo.js" type="text/JavaScript"></script>
  <script language="JavaScript" src="../../../../../../../docs/core/CookieClass.js" type="text/JavaScript"></script>
  <script language="JavaScript" src="../../../../../../../docs/core/displayContent.js" type="text/JavaScript"></script>
  
  <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
	
<a href="../../../../../../../docs/core/index.html"></a>

</head>

<body>

	<script language="JavaScript" type="text/JavaScript">
		try {
			displayInFrames();
		}
		catch (e) {
		document.write("<table width='100%'><tr><td bgcolor='#19355E' align='left' height='42'; valign='top'><p style='color:white;font-size:130%;font-weight:bold;margin-top:4px;margin-bottom:0;'>WebLogic Server<sup>&reg;</sup> 10.0</p><p style='color:white;font-size:110%;margin-top:2px;margin-bottom:4px;'>Code Examples</p></td></tr></table>");
			}
	</script>

  <h1> <script language="JavaScript" type="text/JavaScript">document.write(document.title);</script></h1>
  <p> 
  	<a class="navbutton" href="#files">&nbsp;Files&nbsp;</a> 
	<a class="navbutton" href="#prepare">&nbsp;Prepare&nbsp;</a> 
	<a class="navbutton" href="#run">&nbsp;Run&nbsp;</a> 
	<a class="navbutton" href="#troubleshooting" >&nbsp;Troubleshooting&nbsp;</a>	
	<a class="navbutton" href="#related_topics">&nbsp;Related Topics&nbsp;</a> 
  </p> 

<h2>About the Example </h2>
<!-- InstanceBeginEditable name="about" -->
<p>This example is a package that demonstrates
  an Enterprise JavaBean written to the EJB
  2.0 specification. The example is a stateless
session EJBean called <font face="Courier New" size="-1">TraderBean</font>. </p>
<p> The example demonstrates: </p>
<ul>
  <li>A use case for a session EJB written to the EJB 2.0 specification </li>
  <li>Stateless; client must maintain any state across calls to the EJB</li>
  <li>Using application-defined exceptions and utilities </li>
  <li>A client application </li>
</ul>
<h4> Client Application</h4>
The Client
application performs these steps:
<ol>
  <li>Creates a Trader </li>
  <li>Buys and sells shares of "BEAS", "MSFT", "AMZN",
    and "HWP" <br />
    (The EJB does not actually "buy" or "sell";
    it simulates the actions of accessing a database.) </li>
  <li>Removes the Trader <br />
  </li>
</ol>
The application demonstrates how the client must maintain any persistent state
-- such as the change in the cash account -- across repeated calls to the session
EJB.
All the logic for the balance is encapsulated
in the Client, unlike the <a href="../statefulSession/instructions.html">stateful
session example</a>, where all the persistence is provided by the container and the logic is maintained
in the EJB.<!-- InstanceEndEditable -->
<hr />
<a name="files" id="files"></a>
<h2>Files Used in the Example</h2>
<p class="smaller" >Directory Location:</p>
<p class="smaller" style="font-family:'Courier New',monospace;" ><em>BEA_HOME</em>/wlserver_10.3/samples/server/examples/<!-- InstanceBeginEditable name="PATHTOEXAMPLE" -->src/examples/ejb/ejb20/basic/statelessSession/
<!-- InstanceEndEditable --></p>
<p class="smaller" >(where <span style="font-style:italic;font-family:'Courier New',monospace;COLOR: #000000;">BEA_HOME</span> is the directory containing your WebLogic Server installation)</p>

<!-- InstanceBeginEditable name="files" -->
<table border="1" cellpadding="3" cellspacing="0" >
<tr>
<th><p>File</p>
<p style="font-size:75%;font-weight:normal;margin-top:0em">Click source
files to view code.</p></th>
<th><p>Description</p></th>
</tr>
<tr>
<td><a href="application.xml" target="_blank">application.xml</a></td>
<td>The Java EE standard enterprise application deployment descriptor.</td>
</tr>
<tr>
<td><a href="build.xml" target="_blank">build.xml</a></td>
<td>Ant build file that contains targets for building and running the example.</td>
</tr>
<tr>
<td><a href="Client.html" target="_blank">Client.java</a></td>
<td><p>This class illustrates callinga stateless Session Bean and performing the following exercises:</p>
  <p>- Create a Trader<br />
    - Buy some shares using the Trader<br />
    - Sell some shares using the Trader<br />
    - Remove the Trader </p></td>
</tr>
<tr>
<td><a href="TraderBean.html" target="_blank">TraderBean.java</a></td>
<td><p>TraderBean is a stateless Session Bean. This bean illustrates:</p>
  <p>- No persistence of state between calls to the Session Bean.<br />
    - Looking up values from the Environment.</p></td>
</tr>
<tr>
<td><a href="TradeResult.html" target="_blank">TradeResult.java</a></td>
<td>This class reflects the results of a buy/sell transactions.</td>
</tr>
<tr>
<td><a href="weblogic-application.xml" target="_blank">weblogic-application.xml</a></td>
<td>The WebLogic Server-specific enterprise application deployment descriptor.</td>
</tr>
</table>
<!-- InstanceEndEditable -->
<hr />

<a name="prepare" id="prepare"></a>
<h2>Prepare the Example</h2>
<!-- InstanceBeginEditable name="build" -->


<h3>Prerequisites</h3>
<p>Before working with this example: </p>
<ol>
  <li><a href="http://edocs.bea.com/wls/docs103/../../common/docs100/install/index.html" target="_blank">Install
      WebLogic Server</a>, including the
      examples.</li>
  <li><a href="javascript:reloadTOC('../../../../examples.html#startServer')">Start
      the Examples server.</a></li>
  <li><a href="javascript:reloadTOC('../../../../examples.html#environment')">Set
      up your environment</a>.</li>
</ol>
<h3>Configure WebLogic Server</h3>
<p>&nbsp;&nbsp;No special configuration is
  required for this example</p>
<a name="build" id="build"></a>
<h3>Build and Deploy the Example</h3>
<ol>
  <li>Change to the <code><i>SAMPLES_HOME</i>\server\examples\src\examples\ejb\ejb20\basic\statelessSession</code> directory, where <i>SAMPLES_HOME</i> refers to the main WebLogic Server examples directory, such as <code>d:\beahome\wlserver_10.3\samples</code>.</li>
  <li></li>
  <li>Execute the following command:<br />
      <br />
      <code>ant build</code><br />
      <br />
  This command compiles and stages the example. </li>
  <li>Execute the following command:<br />
      <br />
      <code>ant deploy</code> <br />
      <br />
  This command deploys the example on the <code>wl_server</code> domain
  of your WebLogic Server installation. <br />
    <br />
    The script will build the example and place the files in the correct
  locations in your WebLogic Server distribution: </li>
</ol>
<ul>
  <li>Client.jar file (<font face="Courier New" size="-1">ejb20_basic_statelessSession_client.jar</font>): in <font face="Courier New" size="-1">SAMPLES_HOME\server\examples\build\clientclasses</font> </li>
  <li>EJB (in EAR file): in <font face="Courier New" size="-1">SAMPLES_HOME\domains\wl_server\autodeploy\ejb20_basic_statelessSession.ear</font> <br />
    Running the build script places the EJB in the <font face="Courier New"
size="-1">%applications%</font> directory,
  where it automatically deploys once the server is started. If you are already
  running the server and build another EJB, it is automatically placed in this
  directory and instantly deployed. </li>
</ul>
<p> Additional information on using the build scripts is found in <a href="javascript:reloadTOC('../../../../examples.html#buildScripts')">More
    About Building Examples</a>. </p>
<!-- InstanceEndEditable -->
<hr />
<a name="run" id="run"></a>
<h2>Run the Example</h2>
<!-- InstanceBeginEditable name="run" -->
<ol>
<p>
<li>Complete the steps in the &quot;<a href="#prepare">Prepare
    the Example</a>&quot; section.</li>
<li>Execute the following command (from the
  shell where you <a href="javascript:reloadTOC('../../../../examples.html#environment')">set
  your environment</a>):<br />
    <br />
    <code>ant run </code><br />
    <br />
  This command runs the example.</li>
<li>If you're running the <font face="Courier New" size=-1>Client</font> example, 
you should get output similar to this from the client application:

<pre><font face="Courier New">Beginning statelessSession.Client...

Creating a trader
Buying 100 shares of BEAS.
Buying 200 shares of MSFT.
Buying 300 shares of AMZN.
Buying 400 shares of HWP.
Selling 100 shares of BEAS.
Selling 200 shares of MSFT.
Selling 300 shares of AMZN.
Selling 400 shares of HWP.
Removing the trader

End statelessSession.Client...</font></pre>
</ol>

<!-- InstanceEndEditable -->
<hr />
<h2>Troubleshooting</h2>
<a name="troubleshooting" id="troubleshooting"></a>
<!-- InstanceBeginEditable name="troubleshooting" -->
<ul>
  <li><a href="javascript:reloadTOC('../../../../examples.html#troubleshooting')">General
    Troubleshooting Tips for Examples </a></li>
</ul>
<!-- InstanceEndEditable -->
<hr />
<h2>Related Topics</h2>
<p class="smaller">(Internet connection required.)</p>
<a name="related_topics" id="related_topics"></a> 
<!-- InstanceBeginEditable name="related_topics" -->
<ul>
  <li><a href="http://edocs.bea.com/wls/docs103/ejb/index.html" target="_blank">WebLogic Server Enterprise Java Beans</a>.</li>
<li><a href="http://edocs.bea.com/wls/docs103/api.html" target="_blank">Developing
    Applications on WebLogic Server</a></li>
</ul>
<!-- InstanceEndEditable -->

<hr />	
<p><a href="../../../../copyright.html">Copyright</a> © 1996, 2008, Oracle and/or its affiliates. All  Rights Reserved. </p>

</body>
<!-- InstanceEnd --></html>
